Skip to content

Conversation

@XingY
Copy link
Contributor

@XingY XingY commented Aug 20, 2025

Rationale

Currently, the logic to determine the effective audit behavior is: XML metadata override > API param > table’s default setting (which currently is NONE). With this story, the logic is now updated to Max(xml??tableDefault, api)’s priority. Additionally, the default behavior for samples, dataclass data and assay results are updated to DETAILED. Note that for assay results, the detailed audit logging currently only applies for update/delete actions done using QUS.

Related Pull Requests

Changes

  • Update effective audit log logic to only allow elevated api overrride level
  • Consolidate assay result audit events to a single ExperimentEvent and use QueryUpdateEvent for per row details
  • Handle cross type / folder audit per split
  • Set detail audit level to DETAILED fro samples/dataclass/assayresult

{
void addSummaryAuditEvent(User user, Container c, TableInfo table, QueryService.AuditAction action, Integer dataRowCount, @Nullable AuditBehaviorType auditBehaviorType, @Nullable String userComment);

default void addSummaryAuditEvent(User user, Container c, TableInfo table, QueryService.AuditAction action, Integer dataRowCount, @Nullable AuditBehaviorType auditBehaviorType, @Nullable String userComment, boolean skipAuditLevelCheck)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't seem to be any actual usage of the skipAuditLevelCheck. Is this something that can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used to bypass check for ETL in bulkLoad mode and some other places, it's overriden inAbstractAuditHandler.


@NotNull
@Override
public AuditBehaviorType getDefaultAuditBehavior()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This override looks like it just repeats what TableInfo already specifies. Consider removing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, it actually did mean to override. Fixed.

setAuditBehavior(auditBehaviorType);
}
catch (IllegalArgumentException ignore)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Consider logging a warning about an invalid audit behavior argument here. Same for similar usage in SchemaTableInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
for (Long runId: dataChangeCount.keySet())
{
String userComment = configParameters == null ? null : (String) configParameters.get(AuditUserComment);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This userComment processing can be moved above the loop.

Map<String, Object> extraScriptContext
) throws InvalidKeyException, BatchValidationException, QueryUpdateServiceException, SQLException
{
dataChangeCount = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a LinkedHashMap to retain insertion order so that audit events are consistently added in the same order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return result;
}

private Object lookupDisplayValue(Object o, @NotNull TableInfo fkTableInfo, ColumnInfo fkTablePkCol)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice to see this go away.

@Override
public AuditBehaviorType getAuditBehavior()
@NotNull
public AuditBehaviorType getDefaultAuditBehavior()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should ExpDataClassTableImpl also override this and set to DETAILED?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, ExpDataClassTableImpl is for dataclass type not the data itself. For domains, we have DomainEvent and DomainPropertyEvent.

}
else if (tInfo != null)
{
ExpSampleType sampleType = SampleTypeService.get().getSampleType(c, tInfo.getUserSchema().getUser(), tInfo.getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: No need to call SampleTypeService.get() as this call is being made from within the service itself.

// NOTE: to avoid a diff in the audit log make sure row("rowid") is correct! (not the unused generated value)
row.put(ROW_ID,staticsRow.get(ROW_ID));
}
else if (tInfo != null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tInfo.getUserSchema() could be null. Consider:

else if (tInfo != null)
{
    UserSchema schema = tInfo.getUserSchema();
    if (schema != null)
    {
        ExpSampleType sampleType = getSampleType(c, schema.getUser(), tInfo.getName());
        if (sampleType != null)
        {
            event.setSampleType(sampleType.getName());
            event.setSampleTypeId(sampleType.getRowId());
        }
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@XingY XingY merged commit c0fd1f5 into develop Aug 29, 2025
8 of 9 checks passed
@XingY XingY deleted the fb_defaultAudit branch August 29, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants